package demo;

import javax.annotation.Resource;

public class PowerMockDemoImpl implements PowerMockDemo {

    @Resource
    private StaticClassDemo staticClassDemo;

    /**
     * 通过乘员属性执行静态方法，public类型，无入参无返回值
     */
    public void useStaticMethod_withFiled_withNoReturnAndArgs(){
        System.out.println("-----useStaticMethod_withFiled_withNoReturnAndArgs-----");
        staticClassDemo.noReturnAndArgs();
    }

    /**
     * 通过Class执行静态方法，public类型，无入参无返回值
     */
    public void useStaticMethod_withNoReturnAndArgs(){
        System.out.println("-----exec useStaticMethod_withNoReturnAndArgs-----");
        StaticClassDemo.noReturnAndArgs();
    }

    /**
     * 执行本类中的静态方法，private类型，无入参无返回值
     */
    public void useStaticMethod_noReturnAndArgsWithPrivate(){
        System.out.println("-----exec useStaticMethod_noReturnAndArgsWithPrivate-----");
        noReturnAndArgsWithPrivate();
    }

    /**
     * 通过成员属性调用静态方法，public类型，无入参，int类型返回值
     */
    public void useStaticMethod_withFiled_noArgsWithBasicIntReturn(){
        System.out.println("-----useStaticMethod_withFiled_noArgsWithBasicIntReturn-----");
        int result = staticClassDemo.noArgsWithBasicIntReturn();
        System.out.println("return value= "+ result +";");
    }

    /**
     * 通过Class执行静态方法，public类型，无入参，int类型返回值
     */
    public void useStaticMethod_noArgsWithBasicIntReturn(){
        System.out.println("-----exec useStaticMethod_noArgsWithBasicIntReturn-----");
        int result = StaticClassDemo.noArgsWithBasicIntReturn();
        System.out.println("static class demo result value = "+result+";");
    }

    /**
     * 执行本类中静态方法，private类型，无入参，int类型返回值
     */
    public void useStaticMethod_noArgsWithBasicIntReturnPrivate(){
        System.out.println("-----exec useStaticMethod_noArgsWithBasicIntReturnPrivate-----");
        int result = PowerMockDemoImpl.noArgsWithBasicIntReturnPrivate();
        System.out.println("static class demo result value = "+ result +";");
    }

    /**
     * 通过成员属性调用静态方法，public类型，int类型入参，无返回值
     * @param arg
     */
    public void useStaticMethod_withFiled_noReturnWithIntArg(int arg){
        System.out.println("-----exec useStaticMethod_noReturnWithIntArg-----");
        System.out.println("receive arg = "+ arg +";");
        staticClassDemo.noReturnWithIntArg(arg);
    }

    /**
     * 通过Class执行静态方法，public类型，int类型入参，无返回值
     * @param arg
     */
    public void useStaticMethod_noReturnWithIntArg(int arg){
        System.out.println("-----exec useStaticMethod_noReturnWithIntArg-----");
        System.out.println("receive arg = "+ arg +";");
        StaticClassDemo.noReturnWithIntArg(arg);
    }

    /**
     * 执行本类中静态方法，private类型，int类型入参，无返回值
     * @param arg
     */
    public void useStaticMethod_noReturnWithIntArgPrivate(int arg){
        System.out.println("-----exec useStaticMethod_noReturnWithIntArgPrivate-----");
        System.out.println("receive arg = "+ arg +";");
        PowerMockDemoImpl.noReturnWithIntArgPrivate(arg);
    }

    /**
     * 通过成员属性调用静态方法，public类型，int类型入参，int类型返回值
     * @param arg
     */
    public void useStaticMethod_withFiled_withIntReturnAndArg(int arg){
        System.out.println("-----exec useStaticMethod_withIntReturnAngArg-----");
        System.out.println("receive arg = "+ arg +";");
        int result = staticClassDemo.withIntReturnAndArg(arg);
        System.out.println("return value = "+ result +";");
    }

    /**
     * 通过Class执行静态方法，public类型，int类型入参，int类型返回值
     * @param arg
     */
    public void useStaticMethod_withIntReturnAndArg(int arg){
        System.out.println("-----exec useStaticMethod_withIntReturnAngArg-----");
        System.out.println("receive arg = "+ arg +";");
        int result = StaticClassDemo.withIntReturnAndArg(arg);
        System.out.println("return value = "+ result +";");
    }

    /**
     * 执行本类中静态方法，public类型，int类型入参，int类型返回值
     * @param arg
     */
    public void useStaticMethod_withIntReturnAndArgPrivate(int arg){
        System.out.println("-----exec useStaticMethod_withIntReturnAndArg-----");
        System.out.println("receive arg= "+ arg +";");
        int result = PowerMockDemoImpl.withIntReturnAndArgPrivate(arg);
        System.out.println("result value= "+ result +";");
    }

    public void useStaticMethod_innerMethod_noReturnAndArgs(){
        System.out.println("-----exec useStaticMethod_innerMethod_noReturnAndArgs-----");
        InnerStaticClass.innerMethod_noReturnAndArgs();
    }

    public void useStaticMethod_innerMethod_noReturnAndIntArg(int arg){
        System.out.println("-----exec useStaticMethod_innerMethod_noReturnAndIntArg-----");
        System.out.println("receive arg = "+ arg +";");
        InnerStaticClass.innerMethod_noReturnAndIntArg(arg);
    }

    public void useStaticMethod_innerMethod_intReturnAndNoArg(){
        System.out.println("-----exec useStaticMethod_innerMethod_intReturnAndNoArg-----");
        int result = InnerStaticClass.innerMethod_intReturnAndNoArg();
        System.out.println("result = "+ result +";");
    }

    public void useStaticMethod_innerMethod_intReturnAndIntArg(int arg){
        System.out.println("-----exec useStaticMethod_innerMethod_intReturnAndIntArg-----");
        System.out.println("receive arg = "+ arg +";");
        int result = InnerStaticClass.innerMethod_intReturnAndIntArg(arg);
        System.out.println("result = "+ result +";");
    }

    //=====以下是待测试的private类型的static方法=====

    /**
     * private类型的静态方法，没有入参和返回值
     */
    private static void noReturnAndArgsWithPrivate(){
        throw new UnsupportedOperationException("mock failed!");
    }

    /**
     * private类型的静态方法，没有入参，存在int类型的返回值
     * @return
     */
    private static int noArgsWithBasicIntReturnPrivate(){
        throw new UnsupportedOperationException("mock failed!");
    }

    /**
     * private类型的静态方法，int类型的入参，没有返回值
     * @param num
     */
    private static void noReturnWithIntArgPrivate(int num){
        throw new UnsupportedOperationException("mock failed!");
    }

    /**
     * private类型的静态方法，int类型的入参，返回值入参++
     * @param num
     * @return
     */
    private static int withIntReturnAndArgPrivate(int num){
        throw new UnsupportedOperationException("mock failed!");
    }

    /**
     * 待测试的静态内部类
     */
    public static class InnerStaticClass{
        public static void innerMethod_noReturnAndArgs(){
            throw new UnsupportedOperationException();
        }

        public static void innerMethod_noReturnAndIntArg(int arg){
            throw new UnsupportedOperationException();
        }

        public static int innerMethod_intReturnAndNoArg(){
            throw new UnsupportedOperationException();
        }

        public static int innerMethod_intReturnAndIntArg(int arg){
            throw new UnsupportedOperationException();
        }
    }

}
